package com.qianfeng.smartplatform.controller;/*
 *@Description:
 *@author:赵健
 *@Date:zjzzz 2022/9/9 8:56
 */

import com.qianfeng.smartplatform.dto.R;
import com.qianfeng.smartplatform.pojo.Scene;
import com.qianfeng.smartplatform.service.SceneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/scenes")
public class SceneController {
    @Autowired
    private SceneService service;
@RequestMapping("/scene")
    public R addScene(@RequestBody @Validated Scene scene) {
        service.addScene(scene);
        return R.OK();
    }
    @RequestMapping("/scene/{sceneId}")
    public R findById(@PathVariable Long sceneId) {
        return R.OK(service.getSceneById(sceneId));
    }
    @RequestMapping("/scenes")
    public R findAllByUser() {
        return R.OK(service.getAllScenesByUser());
    }
}
